package csel.model;

import junit.framework.Assert;
import junit.framework.TestCase;

import org.junit.After; 
import org.junit.Before; 
import org.junit.Test; 

public class MapTester extends TestCase {
	public static void main(String args[]) 
	{ 
		junit.textui.TestRunner.run(MapTester.class); 
	} 
	Map map;
	
	@Before
	protected void setUp() throws Exception
	{
		RealTile[][] tiles = new RealTile[100][100];
		for(int i = 0; i < 100; i++)
		{
			for(int j = 0; j<100; j++)
			{
				tiles[i][j] = new RealTile();
				tiles[i][j].setLocation(new Location(i, j));
			}
		}
		map = new Map(tiles);
	}
	
	@Test
	public void testGetTile()
	{
		RealTile testTile = (RealTile) map.getTile(5, 5);
		Location location = testTile.getLocation();
		int x = location.getX();
		int y = location.getY();
		Assert.assertEquals(5, x);
		Assert.assertEquals(5, y);

		
		Tile[][] testTileArray = map.getAdjacentTiles(testTile, 3,3);
		for(int i = 0; i< 7; i++)
		{
			for(int j = 0; j< 7; j++)
			{
				location = testTileArray[i][j].getLocation();
				x = location.getX();
				y = location.getY();
				Assert.assertEquals(i+2, x);
				Assert.assertEquals(j+2, y);
			}
		}
	}
	
	@After protected void tearDown() throws Exception 
	{ 
		super.tearDown(); 
	} 
}
